package com.ftg.youx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ftg.youx.dto.OrdDto;
import com.ftg.youx.entity.OrdPurchaseDetail;
import com.ftg.youx.entity.OrdPurchaseOrder;
import com.ftg.youx.service.IOrdPurchaseOrderService;
import com.ftg.youx.tools.R;
import com.ftg.youx.vo.PurchaseListVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * <p>
 * 进货订单表 前端控制器
 * </p>
 *
 * @author kangjx
 * @since 2024-10-25
 */
@RestController
@RequestMapping("/ord/purchaseOrder")
@Tag(name = "进货订单表")
public class OrdPurchaseOrderController {

    @Resource
    IOrdPurchaseOrderService iOrdPurchaseOrderService;



    /**
     * 分页查询
     * @param page 页码
     * @param pageSize 页大小
     * @return R
     */
    @GetMapping("/list")
    public R<IPage<PurchaseListVo>> list(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize
    ) {
        page = page <= 0 ? 1 : page;
        return iOrdPurchaseOrderService.purchasePage(page, pageSize);
    }

    /**
     * 添加功能
     * @param order 实体
     * @return R
     */
    @PostMapping("/saveOrder")
    public R<Boolean> saveOrder(@RequestBody OrdDto order) {
        return iOrdPurchaseOrderService.saveOrder(order);
    }


    @GetMapping("/getProInfo")
    public String getProInfo(@RequestParam("name") String name,
                             @RequestParam(value = "page",defaultValue = "1") Integer page,
                             @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize){
        return iOrdPurchaseOrderService.getProInfo(name,page,pageSize);
    }

    @GetMapping("/getEmpIdInfo")
    public String getEmpIdInfo(){
        return iOrdPurchaseOrderService.getEmpIdInfo();
    }

}
